<template>
  <div>
    <div>手机号：<input type="text" v-model="accountNumber" /></div>
    <div>密码：<input type="password" v-model="userPassword" /></div>
    <div><button @click="doLogin">登录</button></div>
  </div>
</template>

<script>
import { doLoginApi } from "../../request/api";
export default {
  data() {
    return {
      accountNumber: "",
      userPassword: "",
    };
  },
  methods: {
    doLogin() {
      if (this.accountNumber == "") {
        alert("请输入用户名");
        return;
      } else if (this.userPassword == "") {
        alert("请输入密码");
        return;
      }
      doLoginApi({
        accountNumber: this.accountNumber,
        userPassword: this.userPassword,
      }).then((res) => {
        if (res.status_code == 1) {
          alert("登录成功");
          this.$router.push("/sign");
          localStorage.setItem("token", res.data);
        }
      });
    },
  },
};
</script>

<style>
</style>